package com.ukefu.webim.config.web;

import java.io.File;
import java.io.IOException;

import org.lionsoul.jcseg.tokenizer.core.JcsegException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import com.ukefu.core.UKDataContext;
import com.ukefu.util.ai.AiUtils;
import com.ukefu.util.ai.DicSegment;

@Component
public class XiaoEStartedEventListener implements ApplicationListener<ContextRefreshedEvent> {
	@Value("${web.upload-path}")
    private String path;
	
    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
    	try {
    		DicSegment.loadDic(new File(path , "dic").getAbsolutePath());
			AiUtils.init(UKDataContext.SYSTEM_ORGI);
		} catch (IOException | JcsegException e) {
			e.printStackTrace();
		}
    }
}